#!/bin/bash
echo -- -- begin init taroco... -- --

COMPOSE_FILE=./docker-compose.yml
JAR_DIR=./target

echo -- -- stop and remove old docker-compose containers -- --
if docker-compose -f ${COMPOSE_FILE} ps
    then
        docker-compose -f ${COMPOSE_FILE} stop
        docker-compose -f ${COMPOSE_FILE} rm --force
fi
rm -rf ${JAR_DIR}/*.jar
echo -- -- building jar -- --
mvn clean package -Dmaven.test.skip=true

echo -- -- run docker-compose up -- --
docker-compose -f ${COMPOSE_FILE} up -d --build

docker images|grep none|awk '{print $3 }'|xargs docker rmi
